
package com.scalar.chiptrack.events;

import java.util.Iterator;


/**
 * 
 * @author Balaram Putta
 */
public abstract class SSEventListener
{

    public void handleEvent( SSEvent event ) throws Exception
    {
        handle( event );
    }

    public void handleEvent( SSEventList eventList ) throws Exception
    {
        handle( eventList );
    }

    protected abstract void handle( SSEvent event ) throws Exception;

    /**
     * Default implementation; Sub-classes can over-write if they prefer to handle event lists
     *  
     * @param eventList
     * @throws Exception
     */
    protected void handle( SSEventList eventList ) throws Exception
    {
        if( eventList == null )
        {
            return;
        }

        Iterator iterator = eventList.iterator();
        SSEvent event = null;

        while( iterator.hasNext() )
        {
            event = ( SSEvent ) iterator.next();
            handle( event );
        }

    }
    
    // BR June 28 2005
    // Used in SSEventListenerDefinitionParser#registerListener method
    public boolean equals( Object o )
    {
    	return o.getClass().getName().equalsIgnoreCase( this.getClass().getName() );
    }

}

